package com.library.admin.form;

import com.library.admin.listener.UpdateExemplariesNumberListener;
import com.vaadin.ui.Button;
import com.vaadin.ui.Form;
import com.vaadin.ui.TextField;

public class UpdateExemplariesNumberForm extends Form {
	private static final long serialVersionUID = 1663917448448187840L;
	
	private TextField 	numberTextField;
	private Button 		submitButton;
	private String 		bookIsbn;

	public UpdateExemplariesNumberForm(String bookIsbn) {
		this.bookIsbn = bookIsbn;
		init();
	}

	private void init() {
		setWidth("100%");
		
		numberTextField = new TextField("Nombre d'exemplaires");
		submitButton = new Button("OK");
		
		submitButton.addListener(new UpdateExemplariesNumberListener(this, bookIsbn));
		
		addField("numberTextField", numberTextField);
		addField("submitButton", 	submitButton);
		
		getField("numberTextField").setRequired(true);
		getField("numberTextField").setRequiredError("Le champ \"Nombre d'exemplaires\" est obligatoire");
	}

	public TextField getNumberTextField() {
		return numberTextField;
	}
}
